/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';

@switch-prefix-cls: ~'@{css-prefix}mobile-switch';

.@{switch-prefix-cls} {
  width: var(--ti-mobile-switch-width, 50px);
  height: var(--ti-mobile-switch-height, 30px);
  border: 1px solid var(--ti-mobile-switch-border-color, #e5e5e5);
  border-radius: var(--ti-mobile-switch-border-radius, 40px);
  background-color: var(--ti-mobile-switch-bgcolor, #fff);
  position: relative;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  outline: none;
  transition: all 0.2s ease-in-out;

  &.disabled {
    background-color: var(--ti-mobile-switch-disabled-bgcolor, #f5f5f5);
    cursor: not-allowed;

    &::after {
      border-color: var(--ti-mobile-switch-after-border-color, #ccc);
      cursor: not-allowed;
    }

    &.@{switch-prefix-cls}-checked {
      background-color: var(--ti-mobile-switch-disabled-checked-bgcolor, #b3eee0);
      border-color: var(--ti-mobile-switch-disabled-checked-bgcolor, #b3eee0);

      &::after {
        border-color: rgba(0, 0, 0, 0.1);
      }
    }
  }

  &::after {
    content: '';
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--ti-mobile-switch-font-color, #fff);
    box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--ti-mobile-switch-after-border-color, #ccc);
    position: absolute;
    left: -1px;
    top: 0;
    cursor: pointer;
    transition: left 0.2s ease-in-out, width 0.2s ease-in-out;
    box-sizing: border-box;
  }

  &&-checked {
    border-color: var(--ti-mobile-switch-checked-color, #00c696);
    background-color: var(--ti-mobile-switch-checked-color, #00c696);

    &:after {
      left: calc(~'100% - 28px');
      border-color: var(--ti-mobile-switch-bgcolor, #fff);
    }
  }
}
